/*
 * SortingAlgorythms.h
 *
 *  Created on: Jun 28, 2012
 *      Author: jabberwock
 */

#ifndef SORTINGALGORYTHMS_H_
#define SORTINGALGORYTHMS_H_

//Sorting algorythms
int compare(const void * a, const void * b) { //TODO: remove or rewrite
	return (*(int*) a - *(int*) b);
}

void quick(int* array, int count) {
	qsort(array, count, sizeof(int), compare);
//	cout << "not implemented yet" << endl; //TODO: rewrite
}

void bubble(int* array, int size) {
	bool sorted = false;

	while (!sorted) {
		sorted = true;

		for (int i = 0; i < (size - 1); i++) {
			if (array[i] > array[i + 1]) {
				swap(array[i], array[i + 1]);
				sorted = false;
			}
		}
	}
}

void sort(int* array, int count, void (*__sort_func)(int*, int)) {
	__sort_func(array, count);
}

//TODO: different sorting algorithms that wait for implementation
//void selection(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void insertion(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void shell(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void comb(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void merge(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void heap(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void counting(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void bucket(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void radix(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void flash(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}
//
//void tim(int* array, int count) {
//	cout << "not implemented yet" << endl;
//	exit(EXIT_FAILURE);
//}

#endif /* SORTINGALGORYTHMS_H_ */
